package com.zyl.pts.web.controller;

import com.zyl.pts.config.anno.SystemLog;
import com.zyl.pts.config.enums.CodeAndMessageEnum;
import com.zyl.pts.config.result.Result;
import com.zyl.pts.service.LogService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @version v1.0
 * @ProjectName: product_source
 * @Package: com.zyl.pts.web.controller
 * @ClassName: LogController
 * @Description TODO(日志模块)
 * @Author 翟玉龙
 * @Date 2024/11/19-13:46
 */
@Tag(name = "日志模块", description = "日志模块")
@RestController
@RequestMapping("/log")
public class LogController {
    private final LogService logService;

    public LogController(LogService logService) {
        this.logService = logService;
    }

    /**
     * 分页查询日志信息接口
     * @param pageNum 页码
     * @param pageSize 每页条数
     * @param originalIp 原始ip
     * @return {@link Result }<{@link ? }>
     */
    @SystemLog(business = "分页查询日志信息接口")
    @Operation(summary = "分页查询日志信息接口")
    @GetMapping("/page")
    public Result<?> queryLogPage(
            @RequestParam(name = "pageNum", defaultValue = "1") Integer pageNum,
            @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
            @RequestParam(name = "originalIp", required = false) String originalIp
    ) {
        return Result.success(
                CodeAndMessageEnum.SUCCESS,
                logService.queryLogPage(pageNum, pageSize, originalIp)
        );
    }
}
